# 接口类（员工管理）
import app
import requests


class EnployeeApi:
    # 初始化
    def __init__(self):
        self.enployee_url = app.BASE_url + "/api/sys/user"
        self.enployee_other_url = app.BASE_url + "/api/sys/user/{}"

    # 调用方法（需返还数据）
    # 添加员工
    def insert_api(self, data):
        return requests.post(url=self.enployee_url, json=data, headers=app.token_data)

    # 查询员工
    def select_api(self, enployee_id):
        return requests.get(url=self.enployee_other_url.format(enployee_id), headers=app.token_data)

    # 修改员工
    def update_api(self, enployee_id, update_data):
        return requests.put(url=self.enployee_other_url.format(enployee_id), json=update_data, headers=app.token_data)

    # 删除员工
    def delete_api(self, enployee_id):
        return requests.delete(url=self.enployee_other_url.format(enployee_id), headers=app.token_data)
